package org.deadline.service.config;

import java.util.List;
import org.deadline.model.config.Industry;
import org.deadline.repository.config.IndustryRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class IndustryServiceImpl implements IndustryService {

	@Autowired
    IndustryRepository industryRepository;

	public long countAllIndustrys() {
        return industryRepository.count();
    }

	public void deleteIndustry(Industry industry) {
        industryRepository.delete(industry);
    }

	public Industry findIndustry(Long id) {
        return industryRepository.findOne(id);
    }

	public List<Industry> findAllIndustrys() {
        return industryRepository.findAll();
    }

	public List<Industry> findIndustryEntries(int firstResult, int maxResults) {
        return industryRepository.findAll(new org.springframework.data.domain.PageRequest(firstResult / maxResults, maxResults)).getContent();
    }

	public void saveIndustry(Industry industry) {
        industryRepository.save(industry);
    }

	public Industry updateIndustry(Industry industry) {
        return industryRepository.save(industry);
    }
}
